package middleware

import (
	"github.com/zeromicro/go-zero/rest/httpx"
	"net/http"
	"xialou_platform/app/errorx"
)

type AuthJwtMiddleware struct {
	secret       string
	allowOptions map[string]bool
}

func NewAuthJwtMiddleware() *AuthJwtMiddleware {
	return &AuthJwtMiddleware{
		//jwtModel:  jwtModel,
	}
}

func (m *AuthJwtMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		value := r.Context().Value("claim")
		if value == nil {
			httpx.WriteJson(w, http.StatusBadRequest,
				errorx.NewMsgCodeError(errorx.UnLoginCode, "请登录"))
			return
		}
		next(w, r)
	}
}
